#include "BleMouse.h"
#include <Arduino.h>

void BleMouse::begin(NimBLEHIDDevice* hid) {
  inputMouse = hid->getInputReport(1);  // Report ID 1：鼠标
}

void BleMouse::move(int8_t dx, int8_t dy) {
  uint8_t report[] = {0x00, (uint8_t)dx, (uint8_t)dy, 0};
  inputMouse->setValue(report, sizeof(report));
  inputMouse->notify();
  delay(10);

  uint8_t stop[] = {0x00, 0, 0, 0};
  inputMouse->setValue(stop, sizeof(stop));
  inputMouse->notify();
}

void BleMouse::click(uint8_t buttons) {
  uint8_t report[] = {buttons, 0, 0, 0};
  inputMouse->setValue(report, sizeof(report));
  inputMouse->notify();
  delay(50);

  report[0] = 0;
  inputMouse->setValue(report, sizeof(report));
  inputMouse->notify();
}
